package com.hou;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

public class Test03 {
    public static void main(String[] args) throws IOException {
        //ByteArrayInputStream 内存流
        String data="鸡你太美,鸡你太美,鸡你实在是太美";
        var bais = new ByteArrayInputStream(data.getBytes("gbk"));
        var baos= new ByteArrayOutputStream();
        var bytes = new byte[1024]; //缓冲区
        //将鸡你太美读到输出流中
        while(bais.read(bytes)!=-1){
            baos.write(bytes);
        }
        //默认使用utf-8,jdk10可指定编码输出
        System.out.println(baos.toString("gbk"));
    }
}
